package com.ycsj.goldmedalnewconcept.teacher.adapter;

import android.content.Context;
import android.widget.TextView;

import com.makeramen.roundedimageview.RoundedImageView;
import com.ycsj.common.base.CommonAdapter;
import com.ycsj.common.base.ViewHolder;
import com.ycsj.common.image.ImageUtil;
import com.ycsj.goldmedalnewconcept.R;
import com.ycsj.goldmedalnewconcept.common.HttpAddress;
import com.ycsj.goldmedalnewconcept.teacher.bean.StudentInfo;

import java.util.List;

/**
 * 创建日期：2017/11/10  9:57
 * 描述:展示未分组学生的ListView的适配器
 * 作者:张伟
 */

public class StudentLvAdapter extends CommonAdapter<StudentInfo> {
    private Context context;

    public StudentLvAdapter(Context context, List<StudentInfo> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, StudentInfo info) {
        //学生头像
        RoundedImageView lvHead = holder.getView(R.id.lv_student);

        //学生姓名
        TextView tvName = holder.getView(R.id.tv_student);

        //学生电话号码
        TextView tvTel = holder.getView(R.id.tv_tel);
        tvTel.setText(info.getTel());

        //设置服务器返回的数据
        tvName.setText(info.getName());
        tvName.setText(info.name);

        //设置服务器返回的头像
        if (!info.icon.endsWith(".jpg")) {
            String headUrl = HttpAddress.HEADIMGURL + info.icon + ".jpg";
            ImageUtil.displayImage(context, lvHead, headUrl, R.drawable.head_default);
        } else {
            String headUrl = HttpAddress.HEADIMGURL + info.icon;
            ImageUtil.displayImage(context, lvHead, headUrl, R.drawable.head_default);
        }
    }
}
